﻿import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.15

// 导入自定义包
import com.mycompany.customType 1.0


ApplicationWindow {
    visible: true
    width: 480
    height: 400
    title: qsTr("局域网FTP搜索")

    // 字体加载
    /*FontLoader {
        id: customFont;
        source: "/font/SourceHanSansCN-Normal.otf"
    }
    // 设置字体,默认字体手机端中文显示有问题
    font{family: customFont.name; pixelSize: 14}
    */

    Connections{// 显示消息
        target: searchView.listViewServer.model
        function onSignalShowMsg(msg) {
            dialogShowMsg.showMsgDialog(msg, 5000);
        }
    }

    /*
    header: ToolBar {
        visible: false
        height: 30
        //contentHeight: 15//toolButton.implicitHeight
        Column {
            anchors.fill: parent
            ToolButton {
                //id: toolButton
                height: parent.height
                width: parent.height * 1.5
                text: qsTr("搜索")
                //icon.source: {
                //    if(0 === swipeView.currentIndex)
                //    {
                //        return "/image/refresh.png"
                //    }
                //    return "/image/menuBtn.png"
                //}
                //display: AbstractButton.IconOnly
                font.pixelSize: Qt.application.font.pixelSize * 1
                contentItem: Text {
                    text: parent.text
                    font: parent.font
                    opacity: enabled ? 1.0 : 0.3
                    color: parent.down ? "#17a81a" : "#21be2b"
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                    elide: Text.ElideRight
                }
                background: Rectangle {
                    implicitWidth: 100
                    implicitHeight: 40
                    opacity: enabled ? 1 : 0.3
                    border.color: parent.down ? "#17a81a" : "#21be2b"
                    border.width: 1
                    radius: 2
                }
                onClicked: {
                    if(0 === swipeView.currentIndex)
                    {
                        listViewServer.model.scanServer();
                    }
                }
            }

            Label {
                id: labelWebTitle
                text: qsTr("FTP服务器列表")
                anchors.centerIn: parent
                //horizontalAlignment: Qt.AlignHCenter
                //verticalAlignment: Qt.AlignVCenter
                //Layout.fillWidth: true
            }
        }
    }
    */



    // 主区域
    SwipeView {
        id: swipeView
        anchors.fill: parent
        interactive: false
        //currentIndex: tabBar.currentIndex

        Search{
            id: searchView
        }

        //
        onCurrentIndexChanged: {
            if(0 === swipeView.currentIndex)
            {
            }
        }
    }

    ///////////////////////////////////////////////////////////
    // 显示消息对话框，对话框会自动定时消失
    DialogShowMsg {
        id: dialogShowMsg
    }
}
